//
//  Consume_GD_MonthPayView.m
//  JinFuThree
//
//  Created by 爱尚 on 2018/9/4.
//  Copyright © 2018年 毛韶谦. All rights reserved.
//

#import "Consume_GD_MonthPayView.h"

@implementation Consume_GD_MonthPayView

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self initViews];
    }
    return self;
}

-(void)initViews{
    UIView *line = [[UIView alloc]init];
    line.backgroundColor = ThemeMaoLineColor;
    [self addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.mas_equalTo(self);
        make.height.mas_offset(0.5);
    }];
    UILabel *label = [[UILabel alloc]init];
    label.text = @"月供：";
    label.textColor = HexColor(0x454545);
    label.font = [UIFont systemFontOfSize:13];
    [self addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.mas_left).offset(15);
        make.top.mas_equalTo(self.mas_top).offset(10);
        make.width.mas_offset(@40);
        make.height.mas_offset(@13);
    }];
    
    _monthpayLabel = [[UILabel alloc]init];
    _monthpayLabel.text = @"¥428.25";
    _monthpayLabel.font = UIFontMaoNormal;
    _monthpayLabel.textColor = ThemeMaoRedColor;
    [self addSubview:_monthpayLabel];
    [_monthpayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(label.mas_right);
        make.centerY.height.mas_equalTo(label);
        make.right.mas_equalTo(self.mas_right).offset(-120);
    }];
    
    _instalmentLabel = [[UILabel alloc]init];
    _instalmentLabel.textColor = HexColor(0x999999);
    _instalmentLabel.font = [UIFont systemFontOfSize:13];
    _instalmentLabel.text = @"分期期数是12期";
    [self addSubview:_instalmentLabel];
    [_instalmentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.monthpayLabel);
        make.top.mas_equalTo(self.monthpayLabel.mas_bottom).offset(5);
        make.left.mas_equalTo(label.mas_left);
    }];
    
    _orderBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_orderBtn setTitle:@"预约" forState:UIControlStateNormal];
    [_orderBtn setTitleColor:HexColor(0xFFFFFF) forState:UIControlStateNormal];
    _orderBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    _orderBtn.frame = CGRectMake(ScreenWidthMao-110, 0, 110, 50);
    [self addSubview:_orderBtn];
    CAGradientLayer *caLayer = [CAGradientLayer layer];
    caLayer.frame = self.orderBtn.bounds;
    caLayer.startPoint = CGPointMake(0, 0);
    caLayer.endPoint = CGPointMake(1, 0);
    //设置颜色数组
    caLayer.colors = @[(__bridge id)HexColor(0xE4D1AD).CGColor,
                       (__bridge id)HexColor(0xBEA471).CGColor];
    
    //设置颜色分割点（范围：0-1）
    caLayer.locations = @[@(0.0f), @(1.0f)];
    [self.orderBtn.layer addSublayer:caLayer];
    
    UILabel *tiLabel = [[UILabel alloc]init];
    tiLabel.frame = self.orderBtn.frame;
    tiLabel.text = @"预约";
    tiLabel.font = [UIFont systemFontOfSize:15];
    tiLabel.textAlignment = NSTextAlignmentCenter;
    tiLabel.textColor = HexColor(0xFFFFFF);
    [self addSubview:tiLabel];
    
    _topBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_topBtn setImage:[UIImage imageNamed:@"icon_shang"] forState:UIControlStateNormal];
    [self addSubview:_topBtn];
    [_topBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self);
        make.right.mas_equalTo(self.orderBtn.mas_left);
        make.width.height.mas_offset(@40);
    }];
    
}

@end
